<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>tpblog管理后台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.4 -->
    <link href="/Public/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <!-- FontAwesome 4.3.0 -->
    <link href="/Public/bootstrap/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <!-- Ionicons 2.0.0 --
    <link href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet" type="text/css" />
    <!-- Theme style -->
    <link href="/Public/dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css"/>
    <!-- AdminLTE Skins. Choose a skin from the css/skins 
    	folder instead of downloading all of them to reduce the load. -->
    <link href="/Public/dist/css/skins/_all-skins.min.css" rel="stylesheet" type="text/css"/>
    <!-- iCheck -->
    <link href="/Public/plugins/iCheck/flat/blue.css" rel="stylesheet" type="text/css"/>
    <!--全局自定义css样式-->
    <link href="/Public/Admin/css/common.css">
    <!-- jQuery 2.1.4 -->
    <script src="/Public/plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <script src="/Public/js/global.js"></script>
    <script src="/Public/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="/Public/plugins/layerjs/layer.js"></script><!-- 弹窗js 参考文档 http://layer.layui.com/-->
    <script src="/Public/Admin/js/common.js"></script>
    <script src="/Public/Admin/js/myAjax.js"></script>
    <script src="/Public/Admin/js/main.js"></script>
    <script type="text/javascript">
        function delfunc(obj) {
            layer.confirm('确认删除？', {
                        btn: ['确定', '取消'] //按钮
                    }, function () {
                        $.ajax({
                            type: 'post',
                            url: $(obj).attr('data-url'),
                            data: {act: 'del', del_id: $(obj).attr('data-id')},
                            dataType: 'json',
                            success: function (data) {
                                if (data == 1) {
                                    layer.msg('操作成功', {icon: 1});
                                    $(obj).parent().parent().remove();
                                } else {
                                    layer.msg(data, {icon: 2, time: 2000});
                                }
                                layer.closeAll();
                            }
                        })
                    }, function (index) {
                        layer.close(index);
                        return false;// 取消
                    }
            );
        }

        //全选
        function selectAll(name, obj) {
            $('input[name*=' + name + ']').prop('checked', $(obj).checked);
        }

        function get_help(obj) {
            layer.open({
                type: 2,
                title: '帮助手册',
                shadeClose: true,
                shade: 0.3,
                area: ['90%', '90%'],
                content: $(obj).attr('data-url'),
            });
        }

        function delAll(obj, name) {
            var a = [];
            $('input[name*=' + name + ']').each(function (i, o) {
                if ($(o).is(':checked')) {
                    a.push($(o).val());
                }
            })
            if (a.length == 0) {
                layer.alert('请选择删除项', {icon: 2});
                return;
            }
            layer.confirm('确认删除？', {btn: ['确定', '取消']}, function () {
                        $.ajax({
                            type: 'get',
                            url: $(obj).attr('data-url'),
                            data: {act: 'del', del_id: a},
                            dataType: 'json',
                            success: function (data) {
                                if (data == 1) {
                                    layer.msg('操作成功', {icon: 1});
                                    $('input[name*=' + name + ']').each(function (i, o) {
                                        if ($(o).is(':checked')) {
                                            $(o).parent().parent().remove();
                                        }
                                    })
                                } else {
                                    layer.msg(data, {icon: 2, time: 2000});
                                }
                                layer.closeAll();
                            }
                        })
                    }, function (index) {
                        layer.close(index);
                        return false;// 取消
                    }
            );
        }
    </script>
</head>
<body style="background-color:#ecf0f5;">
 

<body>
<section class="content">
    <div class="container-fluid">
        <div class="panel panel-default">
            <div class="pull-right">
                <a href="" class="btn btn-default glyphicon glyphicon-arrow-left"></a>
            </div>
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title glyphicon glyphicon-list"> 菜单列表</h3>
            </div>
            <div class="panel-body">
                <nav class="navbar navbar-default" role="navigation">
                    <div class="row navbar-form">
                        <button type="button" class="btn btn-primary pull-right glyphicon glyphicon-plus"
                                onclick="goNextPage('/index.php/Manager/Index/menu_operate')"> 增加菜单
                        </button>
                    </div>
                </nav>
                <!--列表-->
                <form action="javascript:void(0);" id="menu_list_form">
                    <table class="table table-bordered table-hover">
                        <tr>
                            <th class="text-center" style="width:100px">选择</th>
                            <th class="text-center" style="width:150px">菜单名称</th>
                            <th class="text-center" style="width:300px;">链接地址</th>
                            <th class="text-center">是否显示</th>
                            <th class="text-center">是否新窗口</th>
                            <th class="text-center">排序</th>
                            <th class="text-center">操作</th>
                        </tr>
                        <?php if(is_array($info)): $i = 0; $__LIST__ = $info;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
                                <td class="text-center menu_checkbox"><input type="checkbox" class="menu_id" name="menu_id" value="<?php echo ($vo["id"]); ?>">
                                </td>
                                <td><?php echo ($vo["html"]); echo ($vo["menu_name"]); ?></td>
                                <td><?php echo ($vo["url"]); ?></td>
                                <td class="text-center">
                                    <img src="/Public/images/common/<?php if($vo["is_open"] == 1): ?>yes_1.png<?php else: ?>no_0.png<?php endif; ?>"
                                         alt="" onclick="updateTabelField('/index.php/Manager','is_open','<?php echo ($vo["id"]); ?>',this);">
                                </td>
                                <td class="text-center">
                                    <img src="/Public/images/common/yes_1.png" alt="">
                                </td>
                                <td class="text-center">
                                    <input type="text" name="" id="" style="width:50px" value="<?php echo ($vo["sort"]); ?>"
                                           onchange="updateSort('/index.php/Manager','sort','<?php echo ($vo["id"]); ?>',this)">
                                </td>
                                <td class="text-center">
                                    <a href="/index.php/Manager/Index/menu_operate/id/<?php echo ($vo["id"]); ?>"
                                       class="btn btn-info glyphicon glyphicon-edit"></a>
                                    <a href="javascript:void(0);" onclick="delMenu('/index.php/Manager','<?php echo ($vo["id"]); ?>');"
                                       class="btn btn-info btn-danger glyphicon glyphicon-trash"></a>
                                </td>
                            </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                        <tr>
                            <td class="text-center" colspan="2">
                                <button class="btn btn-primary" onclick="selectAllMenu('menu_id')">全选</button>
                                <button class="btn btn-primary" onclick="selectNoMenu('menu_id')">全不选</button>
                                <button class="btn btn-primary inverseSelect" onclick="inverseSelect('menu_id')">反选</button>
                            </td>
                            <td>
                                <select name="patch" class="form-control" style="width:50%">
                                    <option value="0">请选择--</option>
                                    <option value="1">开启</option>
                                    <option value="2">取消</option>
                                    <option value="3">删除</option>
                                </select>
                                <button class="btn btn-primary" onclick="batchUpdate('/index.php/Manager')">执行</button>
                            </td>
                            <td colspan="4"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>
</section>
</body>
</html>